﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using IndoReputation.Models.BusinessObject;
using IndoReputation.Models.BusinessObject.Collections;
using IndoReputation.Models.DataAccess;

namespace IndoReputation.Models.BusinessLogic
{
    public class MediaCategoryBOL
    {
        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 4/22/2012  6:03 PM
        /// Todo: Insert an mediaCategory to db
        /// </summary>
        /// <param name="mediaCategory">The mediaCategory.</param>
        /// <returns></returns>
        public static int Insert(MediaCategory mediaCategory)
        {
            try
            {
                mediaCategory.CreateAt = DateTime.Now;
                mediaCategory.CreateBy = MySession.UserID;
                mediaCategory.UpdateAt = null;
                mediaCategory.UpdateBy = null;
                return MediaCategoryDAL.Insert(mediaCategory);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  9:45 AM
        /// Todo: Update a User Exists in Database 
        /// </summary>
        /// <param name="mediaCategory">A mediaCategory.</param>
        /// <returns></returns>
        public static bool Update(MediaCategory mediaCategory)
        {
            try
            {
                mediaCategory.UpdateAt = DateTime.Now;
                mediaCategory.UpdateBy = MySession.UserID;
                return MediaCategoryDAL.Update(mediaCategory);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:36 AM
        /// Todo: Delete a User Existst in Database
        /// </summary>
        /// <param name="mediaCategory">A mediaCategory.</param>
        /// <returns></returns>
        public static bool Delete(int mediaCategoryID)
        {
            try
            {
                return MediaCategoryDAL.Delete(mediaCategoryID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/29/2011  5:23 PM
        /// Todo: Get All MediaCategory
        /// </summary>
        /// <returns></returns>
        public static MediaCategoryList GetAllMediaCategory()
        {
            try
            {
                return MediaCategoryDAL.GetAllMediaCategory() ?? new MediaCategoryList();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:40 AM
        /// Todo: Select a User existst in Database
        /// </summary>
        /// <param name="mediaCategoryID">The mediaCategory ID.</param>
        /// <returns></returns>
        public static MediaCategory GetMediaCategoryById(int mediaCategoryID)
        {
            try
            {
                return MediaCategoryDAL.GetMediaCategoryById(mediaCategoryID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:40 AM
        /// Todo: Select a User existst in Database
        /// </summary>
        /// <param name="mediaCategoryID">The mediaCategory ID.</param>
        /// <returns></returns>
        public static MediaCategoryShort GetMediaCategoryShortById(int mediaCategoryID)
        {
            try
            {
                return MediaCategoryDAL.GetMediaCategoryShortById(mediaCategoryID) ?? new MediaCategoryShort();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        public static MediaCategory GetNameByMediaID(int mediaID)
        {
            try
            {
                return MediaCategoryDAL.GetNameByMediaID(mediaID) ?? new MediaCategory();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
    }
}